﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Business.ProductsTypeManagement;
using Business.ProductsTypeManagement.Dto;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Domain.Repositories;

namespace Business.Controllers
{
    [RemoteService]
    [Area("Business")]
    [Route("api/business/productsType")]
    public class ProductsTypeController : AbpController
    {
        private readonly IProductsTypeAppService _ProductsAppService;

        public ProductsTypeController(IProductsTypeAppService ProductsAppService)
        {
            _ProductsAppService = ProductsAppService;
        }

        /// <summary>
        /// 新增产品类型
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("type-post")]
        public Task<MenuItem> AddProductType(MenuItem input)
        {
            return _ProductsAppService.AddProductType(input);
        }
        /// <summary>
        /// 获取菜单项列表
        /// </summary>
        /// <param name="pId"></param>
        /// <returns></returns>
        [HttpGet]
        [Route("menu-item-list")]
        public Task<PagedResultDto<TreeDto>> GetMenuItemList(int pId)
        {
            return _ProductsAppService.GetMenuItemList(pId);
        }
        /// <summary>
        /// 删除菜单项
        /// </summary>
        /// <param name="productsTypeId">要删除的菜单项的 ID</param>
        /// <returns>操作是否成功的布尔值</returns> 
        [HttpDelete]
        [Route("delete-product-type")]
        public Task<bool> DeleteProductType(int productsTypeId)
        {
            return _ProductsAppService.DeleteProductType(productsTypeId);
        }
        /// <summary>
        /// 获取菜单项详情
        /// </summary>
        /// <param name="productsTypeId">菜单项 ID</param>
        /// <returns></returns>
        [HttpGet]
        [Route("find-product-type")]
        public  Task<MenuItem> GetProductType(int productsTypeId)
        {
            return _ProductsAppService.GetProductType(productsTypeId);
        }

        /// <summary>
        /// 修改菜单项
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        [Route("update-product-type")]
        public  Task<MenuItem> UpdateProductType(MenuItem input)
        {
            return _ProductsAppService.UpdateProductType(input);
        }
    }
}
